package com.neborosoft.FlyingDog.android.playing.modes;

import android.app.Activity;
import com.neborosoft.FlyingDog.R;
import com.neborosoft.FlyingDog.android.gui.adapters.listview.AlbumListAdapter;
import com.neborosoft.FlyingDog.android.gui.adapters.listview.ArtistListAdapter;
import com.neborosoft.FlyingDog.android.gui.adapters.listview.SongsPlayListAdapter;
import com.neborosoft.FlyingDog.logic.database.providers.TagsTreeWithSongsAndArtistsNavigation;
import com.neborosoft.android.gui.adapters.listview.ViewArrayAdapter;
import com.neborosoft.android.gui.wrappers.ListViewSwitcher;
import com.neborosoft.lib.FlyingDogRuntimeException;
import com.neborosoft.lib.collections.tree.MultiStepsNavigationTree;

/**
 * Created with IntelliJ IDEA.
 * User: CM
 * Date: 25.02.13
 * Time: 23:28
 * To change this template use File | Settings | File Templates.
 */
public abstract class TagsMode extends PlayingModeWithNavigationTabs{
    public TagsMode(Activity activity, ListViewSwitcher listViewSwitcher, MultiStepsNavigationTree tree) {
        super(activity, listViewSwitcher, tree);
    }

    @Override
    protected int getTabsLevel() {
        return TagsTreeWithSongsAndArtistsNavigation.TAGS_LEVEL;
    }

    abstract protected int getSongsTabId();

    @Override
    protected int getStepsCountByTabId(int tabId) {
        if(tabId == getSongsTabId()){
            return TagsTreeWithSongsAndArtistsNavigation.STEPS_COUNT_FROM_TAGS_TO_SONGS;
        } else {
            return MultiStepsNavigationTree.DEFAULT_STEPS_COUNT;
        }
    }

    @Override
    protected int getListViewResourceIdForLevel(int level) {
        if(level == TagsTreeWithSongsAndArtistsNavigation.TAGS_LEVEL ||
                level == TagsTreeWithSongsAndArtistsNavigation.SONGS_LEVEL){
            return Constants.listViewSwitcherResource;
        } else {
            return Constants.gridViewSwitcherResource;
        }
    }

    protected abstract Class<? extends ViewArrayAdapter> getTagsLevelAdapterClass();

    @Override
    protected Class<? extends ViewArrayAdapter> getListViewAdapterClass(int level) {
        switch(level){
            case TagsTreeWithSongsAndArtistsNavigation.TAGS_LEVEL: return getTagsLevelAdapterClass();
            case TagsTreeWithSongsAndArtistsNavigation.ARTISTS_LEVEL: return ArtistListAdapter.class;
            case TagsTreeWithSongsAndArtistsNavigation.ALBUMS_LEVEL: return AlbumListAdapter.class;
            case TagsTreeWithSongsAndArtistsNavigation.SONGS_LEVEL: return SongsPlayListAdapter.class;
            default: throw new FlyingDogRuntimeException("invalid level request");
        }
    }
}
